<?php

namespace Apps\AppApi\Method\Note;

use Apps\AppApi\Method\BaseMethod;
use PhalconPlus\Api\Common\ResultStatus;
use Phalcon\Mvc\Model;
use Apps\Common\Models\Members;


/**
 * 获取记账本会员详情
 * @author      545
 * @date        2016年3月4日
 * @version     1.1.2
 * @copyright   Copyright 2015 meelier.com
 */
class GetMember extends BaseMethod
{
    
    private $success = 0;
    private $id = 0;

    public function run()
    {
        //验证是否登录
        if(false == $this->verifyUserAuth()){
            return false;
        }
        
        $userid = $this->getUserAuth()->userId;
        
        $id = intval($this->getDataItem('id',0));
        //验证成功
        if ($id == 0) {
            return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '业务参数不全');
        }
        
        $model = Members::findFirst(['where'=>"member_id = {$id} AND user_id ={$userid} ",'columns'=>'member_id,member_name,member_tel,remark']);
        
        if ($model) {
            $info = $model->toArray();
            $this->setResult($info);
        }
        else{
            $this->setResult(['success'=>0,'message'=>'获取失败！']);
        }
        
        
    }

}